<template>
	<view>
		<u-search placeholder="商品编码" :clearabled="true" v-model="goodsNumber" border-color="#606266" @custom="getBHByGoodsNumber" ></u-search>
		<u-card padding="16" v-for="(item,index) in dataList" :key="index">
			<view class="" slot="head">
				<view class="wrap">
					<u-row>
						<u-col span="12">
							<view class="weikaishi3 lanse">
								<span>{{item.goodsName}}</span>
							</view>
						</u-col>
						
					</u-row>
					<u-row>
						<u-col span="6" text-align="left">
							<view class="weikaishi6">
								<span><u-icon name="map" size="26" labelSize="13px" labelColor="#000000" label="编号"></u-icon>：{{item.goodsNumber}}</span>
							</view>
						</u-col>
						<u-col span="6" text-align="left">
							<view class="weikaishi6">
								<span><u-icon name="map" size="26" labelSize="13px" labelColor="#000000" label="数量"></u-icon>：{{item.numb}}</span>
							</view>
						</u-col>
					</u-row>
					<u-row>
						<u-col span="6" text-align="left">
							<view class="weikaishi4 ">
								<span><u-icon name="car" size="29" labelSize="14px" labelColor="#000000" label="原库位" color="#000000"></u-icon>{{item.positionNumber}}</span>
							</view>
						</u-col>
						
						<u-col span="6" text-align="left">
							
							<view class="weikaishi4">
								<span><u-icon name="coupon" size="29" labelSize="14px" labelColor="#000000" label="目标库位"></u-icon>{{item.jpositionNumber}}</span>
							</view>
						</u-col>
					</u-row>
					<u-row>
						<u-col span="12" text-align="left">
							<view class="weikaishi4 ">
								<button type="primary" size="default" @click="toBh(item)">补货</button>
							</view>
						</u-col>
					</u-row>
				</view>
			</view>
			
		</u-card>
		<view>
			<u-calendar v-if="false"  v-model="show" mode="date" max-date="2070-01-01" @change="change" ></u-calendar>
		</view>
		<!-- <u-popup v-model="popupShow" mode="center" closeable width="660rpx" height="720rpx" border-radius="10">
			<view class="u-text-center u-m-t-20 weikaishi3"><u-icon name="order" size="30" labelSize="15px" labelColor="#000000" label="拣货明细"></u-icon></view>
			<u-card padding="16" v-for="(item,index) in dataList2" :key="index">
				<view class="" slot="head">
					<view class="wrap">
						<u-row>
							<u-col span="12">
								<view class="weikaishi3 lanse">
									<span>{{item.storageGoodsname}},{{item.goodsNo}}</span>
								</view>
							</u-col>
						</u-row>
					</view>
				</view>
				<view class="" slot="body">
					<view class="wrap">
						<u-row>
							<u-col span="5" text-align="center">
								<view class="weikaishi4 u-line-1 u-m-t-10">
									<span>批次</span>
								</view>
							</u-col>
							<u-col span="3" text-align="center">
								<view class="weikaishi4 u-line-1 u-m-t-10">
									<span>应拣</span>
								</view>
							</u-col>
							<u-col span="4" text-align="center">
								<view class="weikaishi4 u-line-1 u-m-t-10">
									<span>实拣</span>
								</view>
							</u-col>
						</u-row>
						<u-row v-for="(item1,index1) in item.list" :key="item1.id">
							<u-col span="5" text-align="center">
								<view class=" u-m-t-10 weikaishi4 huanghang">
									<span>{{item1.storageBatchnumber}}</span>
								</view>
							</u-col>
							<u-col span="3" text-align="center" v-if="item1.storageNumber == item1.realNum">
								<view class=" u-m-t-10 weikaishi4 yiwancheng">
									<span>{{item1.storageNumber}}</span>
								</view>
							</u-col>
							<u-col span="3" text-align="center" v-else>
								<view class=" u-m-t-10 weikaishi4">
									<span>{{item1.storageNumber}}</span>
								</view>
							</u-col>
							<u-col span="4" text-align="center" v-if="item1.storageNumber == item1.realNum">
								<view class=" u-m-t-10 weikaishi4 yiwancheng">
									<span>{{item1.realNum}}</span>
								</view>
							</u-col>
							<u-col span="4" text-align="center" v-else>
								<view class=" u-m-t-10 weikaishi4">
									<span>{{item1.realNum}}</span>
								</view>
							</u-col>
						</u-row>
					</view>
				</view>
			</u-card>
		</u-popup> -->
		<view>
			<u-toast ref="uToast" />
		</view>
		
	</view>
</template>
<script>

	export default {
		data() {
			return {
				setMentiontime:'',
				dataList: [],
				dataList2: [],
				show:false,
				popupShow:false,
				areanumberlist:[],
				goodsNumber:''
			}
		},
		onLoad(open) {
			//#ifdef H5 || APP-PLUS
			this.flex = 'u-flex'
			//#endif
			this.refresh()
		},
		filters:{
			formatDate(value) {
			      if (!value) return ''; // 如果没有值，返回空字符串
			      const date = new Date(value); // 将日期字符串转换为 Date 对象
			      const year = date.getFullYear(); // 获取年份
			      const month = String(date.getMonth() + 1).padStart(2, '0'); // 获取月份，+1 是因为月份从 0 开始
			      const day = String(date.getDate()).padStart(2, '0'); // 获取日期
			      return `${year}-${month}-${day}`; // 返回格式化的日期字符串
			    }

		},
		onShow() {
			this.refresh()
		},
		onPullDownRefresh() {
			this.refresh()
			uni.stopPullDownRefresh()
		},
		methods: {
			//补货
			toBh(item){
				console.log(item)
				this.$Router.push({
					name: 'replenishGoods',
					params: {
						id: item.id
					},
				});
			},
			getBHByGoodsNumber(value){
				 console.log(123)
				 console.log(value)
				 let dataList1 = [];
				for(let item of this.dataList) {
					if(item.goodsNumber.includes(value)){
						dataList1.push(item)
					}
				}
				this.dataList = dataList1
				if(value == null || value == '' ){
					this.refresh()
				}
			},
			checkboxChange(e){
				console.log(e)
			},
			refresh(){
				uni.showLoading({
					title: '加载中...'
				})
				this.$http.post('/rest/bh/bhList',{
				},{
					params: {
					},
					header: {
						'Authorization' :uni.getStorageSync('token'),
					}
				}).then(res => {
					this.dataList = res.data.data
					uni.hideLoading()
				})
				
			},
		},
	}
</script>
<style lang="scss">
	.huanhang{
		word-break:break-all;
	}
</style>